import express from 'express';
import multer from 'multer';
import { chat, processDocument, generateQuestions } from '../controllers/question.controller';

const router = express.Router();
const upload = multer({ dest: 'uploads/' });

// 请求验证中间件
const validateChatRequest = (req: express.Request, res: express.Response, next: express.NextFunction) => {
  if (!req.body.message) {
    return res.status(422).json({
      code: 1,
      message: '消息不能为空'
    });
  }
  next();
};

// 基础对话
router.post('/chat', validateChatRequest, chat);

// 处理文档生成题目
router.post('/process-document', upload.single('file'), processDocument);

// 生成特定类型题目
router.post('/generate-questions', generateQuestions);

export default router; 